﻿@model List<MenuItem>

@{
    List<MenuItem> menuList = Model;
}
<!--start_Menu-->
<div id="sidebar" >
    <!--sidebar-shortcuts-->
    @Html.Partial("_SideBarShortcut") 
    
    @*@if(GimsMembership.CurrentUserName == "1100200282546")
    {
        menuList.Add(new MenuItem{NavigateUrl = Url.Action("Index", "AbsenceAdmin"), Text = "ข้อมูลการลารายวัน"});
        menuList.Add(new MenuItem{NavigateUrl = Url.Action("AbsenceQuotaUsed", "AbsenceAdmin"), Text = "ข้อมูลการลารายบุคคล"});
    }*@
     
    <!-- Menu -->
    <ul class="nav nav-list">
		@foreach (var stItem in menuList)
		{
			bool insideSubItem;
            bool isSameController = Html.IsSameControllerAndAction(stItem, out insideSubItem);
			string className = isSameController || insideSubItem ? " active " : string.Empty;
			className += insideSubItem ? " open " : string.Empty;
			string activeString = isSameController || insideSubItem ? string.Format(" class='{0}'", className) : string.Empty;
		
			if (stItem.MenuItems == null || stItem.MenuItems.Count == 0)
			{
                <li @Html.Raw(activeString)>
                    <a href="@(string.IsNullOrWhiteSpace(stItem.NavigateUrl) ? "#" : Url.Content(stItem.NavigateUrl))">
                        <i class="@stItem.Icon"></i>
                        <span>@stItem.Text</span>
                    </a>
                </li>
			}
			else
			{
				<li @Html.Raw(activeString)><a href="#" class="dropdown-toggle"><i class="@stItem.Icon"></i><span>@stItem.Text</span><b class="arrow icon-angle-down"></b></a>
					<ul class="submenu">
						@foreach (var ndItem in stItem.MenuItems)
						{
							bool isThisSubIsSameController = Html.IsSameController(ndItem, out insideSubItem) && ndItem.NavigateUrl != "#" && !ndItem.NavigateUrl.StartsWith("javascript");
							var classNameInSub = string.Empty;
                               
							if (isThisSubIsSameController)
							{
								classNameInSub = " class=active";
							}
							<li @classNameInSub><a href="@Url.Content(ndItem.NavigateUrl)"><i class="icon-double-angle-right"></i>@ndItem.Text</a></li>
						}
					</ul>
				</li>
			}
		}
	</ul>
	  
	<!--collape-buttton-->
	<div id="sidebar-collapse">
		<i class="icon-double-angle-left"></i>
	</div> 
</div > 